local compileAndRemoveIfNeeded = function(f)
  if f == 'init.lua' then return end
  local _,ext = f:match("(.+)%.(.+)")
  if ext ~= 'lua' then return end

  if file.exists(f) then
    print('Compiling:', f)
    node.compile(f)
    file.remove(f)
  end
  collectgarbage()
end

local luaFiles = file.list()
for f,_ in pairs(luaFiles) do compileAndRemoveIfNeeded(f) end

compileAndRemoveIfNeeded = nil
luaFiles = nil
collectgarbage()
